﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using RuleCode.Common;

namespace map.member
{
    public partial class pfriendsRel : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            AjaxPro.Utility.RegisterTypeForAjax(typeof (AjaxFunction ));
            if (!IsPostBack)
            {
                BindMainWebPage();
            }
        }

        #region 辅助方法
        
        private void BindMainWebPage()
        {
            if (Request["type"] != null && AliApi.appUserId !=string.Empty )
            {
                string SqlStr = "exec GetPosibleFriends @dtype= "+Request ["type"].ToString ()+" ,@userid='"+AliApi.appUserId +"'";
                DataSet dSet = SqlHelper.Instance.ExecuteQuery(SqlStr );
                if (dSet.Tables.Count > 0)
                {
                    this.MainWebPager.DataSource = dSet.Tables[0];
                    this.MainWebPager.DataBind();
                }
            }
        }

        public string GetUlHtml(string name,string collageName,string jSchoolName,string sSchoolName,string lastEmployeeName)
        {
            string result = string.Empty;
            result += "<ul>";

            if (name != string.Empty)
                result += "<li>姓名："+name+"</li>";
            if (jSchoolName != string.Empty)
                result += "<li style=\"padding-left:30px\" title =\"初中\">      " + jSchoolName + "</li>";
            if (sSchoolName != string.Empty)
                result += "<li style=\"padding-left:30px\" title =\"高中\">      " + sSchoolName + "</li>";
            if (collageName != string.Empty)
                result += "<li style=\"padding-left:30px\" title =\"大学\">      " + collageName + "</li>";
            if (lastEmployeeName != string.Empty)
                result += "<li style=\"padding-left:30px\" title =\"曾经工作单位\">      " + lastEmployeeName + "</li>";
            result += "</ul>";
            return result;
        }
        #endregion

        #region 事件
        protected void MainWebPager_PageIndexChanged(object sender, RuleCode.Controls.PageChangedEventArgs e)
        {
            MainWebPager.CurrentPageIndex = e.NewPageIndex;
            BindMainWebPage();
        }

        protected void UpdatePageButton_Click(object sender, EventArgs e)
        {
            BindMainWebPage();
        }
        #endregion
    }
}
